package com.bjsdzk.common.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class SimpleDateFormatUtils {

    public static SimpleDateFormat getYMSDF() {
        return new SimpleDateFormat("yyyy-MM");
    }

    public static SimpleDateFormat getYMDSDF() {
        return new SimpleDateFormat("yyyy-MM-dd");
    }

    public static SimpleDateFormat getYMDHSDF() {
        return new SimpleDateFormat("yyyy-MM-dd HH");
    }

    public static SimpleDateFormat getYMDHMSSDF() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    }

    public static String getHM(Date date) {
        SimpleDateFormat format = new SimpleDateFormat("HH:mm");
        String fmtDate = format.format(date);
        return fmtDate;
    }

    public static String getHMM(Date date) {
        SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
        String fmtDate = format.format(date);
        return fmtDate;
    }

    public static SimpleDateFormat getDD() {
        return new SimpleDateFormat("dd");
    }

    public static SimpleDateFormat getMM() {
        return new SimpleDateFormat("MM");
    }

    public static String mongoToHMM(Date date) {
        //mongo时差
        Calendar instance = Calendar.getInstance();
        instance.setTime(date);
        instance.add(Calendar.HOUR_OF_DAY, -8);

        SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
        String fmtDate = format.format(instance.getTime());

        return fmtDate;
    }
}
